<?php
header('Content-Type: application/json');
require_once 'config.php';

$response = ['code' => 200];

try {
    $sql = "SELECT monthly_price, yearly_price, lifetime_price FROM price_settings LIMIT 1";
    $result = $conn->query($sql);
    
    if ($result->num_rows > 0) {
        $response['data'] = $result->fetch_assoc();
    } else {
        $response['data'] = [
            'monthly_price' => 0.00,
            'yearly_price' => 0.00,
            'lifetime_price' => 0.00
        ];
    }
} catch (Exception $e) {
    $response['code'] = 500;
    $response['message'] = '服务器错误: ' . $e->getMessage();
} finally {
    $conn->close();
}

echo json_encode($response);
?>